package com.wqr.mobile.android.ui.pullfresh;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;

import com.wqr.mobile.android.ui.R;
import com.wqr.mobile.android.ui.widget.PullToRefreshView;
import com.wqr.mobile.android.ui.widget.PullToRefreshView.OnFooterRefreshListener;
import com.wqr.mobile.android.ui.widget.PullToRefreshView.OnHeaderRefreshListener;

public class TestGridView extends Activity implements OnHeaderRefreshListener, OnFooterRefreshListener {
	PullToRefreshView mPullToRefreshView;
	GridView mGridView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_grid);
		mPullToRefreshView = (PullToRefreshView) findViewById(R.id.main_pull_refresh_view);
		mGridView = (GridView) findViewById(R.id.gridview);
		mGridView.setAdapter(new DataAdapter(this));
		mPullToRefreshView.setOnHeaderRefreshListener(this);
		mPullToRefreshView.setOnFooterRefreshListener(this);

	}

	@Override
	public void onFooterRefresh(PullToRefreshView view) {
		mPullToRefreshView.postDelayed(new Runnable() {

			@Override
			public void run() {
				mPullToRefreshView.onFooterRefreshComplete();
			}
		}, 1000);
	}

	@Override
	public void onHeaderRefresh(PullToRefreshView view) {
		mPullToRefreshView.postDelayed(new Runnable() {

			@Override
			public void run() {
				// 设置更新时间
				// mPullToRefreshView.onHeaderRefreshComplete("最近更新:01-23 12:01");
				mPullToRefreshView.onHeaderRefreshComplete();
			}
		}, 1000);

	}
}
